package com.ctrip.cat;

import com.dianping.cat.Cat;
import com.dianping.cat.message.Event;
import com.dianping.cat.message.Transaction;

/**
 * @description:
 * @author: lunjiawang
 * @date: 2018/10/9 11:48
 **/
public class HelloTest {
    public static void main(String[] args) {
        String pageName = "";
        String serverIp = "";
        double amount = 0;
        Transaction t = Cat.newTransaction("URL", pageName);
        try{
            //记录一个事件
            Cat.logEvent("URL.Server", serverIp, Event.SUCCESS, "ip="+serverIp+"&...");
            //记录一个业务指标
            Cat.logMetricForCount("PayCount");
            //记录一个业务指标，记录支付金额
            Cat.logMetricForSum("PayAmount", amount);

            System.out.println("your business");

            //设置事务状态
            t.setStatus(Transaction.SUCCESS);
        }catch (Exception e){
            t.setStatus(e);
        }finally {
            t.complete();
        }
    }
}
